<?php

namespace Gnway\Ticket\Rest\Contracts;

use Exception;

/**
 * Class AbstractHook
 *
 * @package Gnway\Ticket\Rest\Contracts
 */
abstract class AbstractHook implements HookInterface
{

  /**
   * @inheritDoc
   */
  public function before()
  {
    return NULL;
  }

  /**
   * @inheritDoc
   */
  public function after()
  {
    return NULL;
  }

  /**
   * @inheritDoc
   */
  public function returning($response)
  {
    return NULL;
  }

  /**
   * @inheritDoc
   */
  public function exception(Exception $ex)
  {
    return NULL;
  }

  /**
   * @inheritDoc
   */
  public function isAlive(string $hook): bool
  {
    $disables = $this->disables();

    return empty($disables) || !in_array($hook, $disables);
  }

  /**
   * Disable hooks
   *
   * @return array
   */
  protected function disables(): array
  {
    return [];
  }
}